<include file="public/header"/>
<body>

<!--main-->
<style type="text/css">
body{ background:#f4f4f4;}
</style>
<div class="pPersonal-warp" style="padding-bottom:0;">
  <div class="bg-green">
  </div>
  <div class="pFill-name">
    <h3 class="t">{$config['index_company_name']}-{$goods['goods_name']}</h3>
    <div class="c">
      <label>开球时间</label>
      {$yd_date}&ensp;&ensp;{$yd_week}&ensp;&ensp;{$yd_time}
    </div>
  </div>
  <form id="order">
  <div class="pFill-filed">


    <dl class="clearfix">
      <dt>姓名</dt>
      <dd>
        <input type="text" class="inpt" placeholder="请添加您的姓名" name="username" value="{$username}">
      </dd>
    </dl>


    <dl class="clearfix">
      <dt>手机号</dt>
      <dd>
        <input type="number" class="inpt" placeholder="请输入联系人号码" name="phone" value="{$phone}">
      </dd>
    </dl>

    <dl class="clearfix">
      <dt>优惠卷</dt>
      <dd>
        <select name="coupon_id" id="coupon" style="width: 50%" class="form-control">
          <option value="0" selected >优惠卷</option>
          <volist name="coupon" id="vo">
            <option value="{$vo.coupon_id}-{$vo.amount}" >{$vo.title}--{$vo.amount}</option>
          </volist>
        </select>
      </dd>
    </dl>


  </div>
    <input type="hidden" name="amount"
    <if condition="$coach neq ''">
      value="{:strtotime($user.vip_time) > time() && $user.vip ? $duoxuan_count *($coach.coach_price+$goods['vip_price']) : $duoxuan_count *$coach.coach_price+$goods['amount'] }"
      <else/>
      value="{:strtotime($user.vip_time) > time() && $user.vip ? $duoxuan_count * $goods['vip_price'] :  $goods['amount'] }"
    </if>  >
    <input type="hidden" name="goods_id" value="{$goods['goods_id']}">
    <input type="hidden" name="coach_id" value="{$coach.coach_id}">
    <input type="hidden" name="order_sn" value="{$order_sn}">
    <input type="hidden" name="date" value="{$yd_date}">
    <input type="hidden" name="time" value="{$yd_time}">
    <input type="hidden" name="week" value="{$yd_week}">
    <input type="hidden" name="duoxuan" value="{$duoxuan}">
  <textarea class="evaluat-area" placeholder="点击在此处添加留言" name="user_note" ></textarea>
  <div class="pFill-filed">
    <dl class="clearfix">
      <dt>教练指导费</dt>
      <dd><span class="c-green">￥<if condition="$coach neq ''">{$coach.coach_price}<else/>0</if></span></dd>
    </dl>
    <dl class="clearfix">
      <dt>球位费（时长）X <if condition="$duoxuan_count neq ''">{$duoxuan_count}<else/>1</if></dt>
      <dd><span class="c-green" id="duration">￥ {:strtotime($user.vip_time) > time() && $user.vip ? $duoxuan_count* $goods['vip_price'] : $goods['amount'] }</span></dd>
    </dl>
  </div>
  </form>
  <div class="pFill-save">
    <a href="javascript:;" class="s-btn" onClick="add()" >
      全额付款￥
      <strong  class="sum">
        <if condition="$coach neq ''">
          {:strtotime($user.vip_time) > time() && $user.vip ? $duoxuan_count * ($coach.coach_price+$goods['vip_price']) : $duoxuan_count* $coach.coach_price+$goods['amount'] }
          <else/>
          {:strtotime($user.vip_time) > time() && $user.vip ? ($duoxuan_count * $goods['vip_price']) : ($goods['amount']) }
        </if>
      </strong>立即预定
    </a>
  </div>
</div>

<script>
    $(function () {
        $(".pFill-pup .close,.pFill-marsk").click(function () {
            $(".pFill-marsk").hide();
            $(".pFill-pup").hide();
            $('html').css({"overflow-y":"auto"});
        });

      console.log('{$duoxuan_count}')
      console.log('{$original_price}')
      $('#coupon').on('change',function(){


        if ($(this).val() != 0){
          $(this).val().split('-')[1];
          let  sum = ( "{$duoxuan_count  > 1 ? $original_price : ( $goods['amount'])}" *1) - ($(this).val().split('-')[1] *1);
          $("input[name='amount']").val(sum);
          $("#duration").html("￥ {$duoxuan_count  > 1 ? $original_price : ( $goods['amount'])} - "+$(this).val().split('-')[1]+' = '+sum);
          $(".sum").html(sum);
          $(".li_sum").html("<label>付款方式</label> 全额付款 ￥ "+sum);
        }else {
          $("input[name='amount']").val("{$duoxuan_count * $goods['vip_price']}");
          $("#duration").html("￥ {$duoxuan_count * $goods['vip_price']}");
          $(".sum").html("{$duoxuan_count * $goods['vip_price']}");
          $(".li_sum").html("<label>付款方式</label> 全额付款 ￥ {$duoxuan_count * $goods['vip_price']}");
        }

      });

    })


    function add() {
        $(".pFill-marsk").show();
        $(".pFill-pup").show();
        $('html').css({"overflow-y":"hidden"});
    }
</script>

<!--弹窗-->
<div class="pFill-marsk">
</div>
<div class="pFill-pup">
  <a href="javascript:;" class="close iconfont">&#xe60c;</a>
  <h3 class="tit">球场预定</h3>
  <ul class="row">
    <li>
      <label>订单编号</label>
      {$order_sn}</li>
    <li>
      <label>球场名称</label>
      {$config['index_company_name']}-{$goods['goods_name']}</li>
    <li>
      <label>预约时间</label>
      {$yd_date}&ensp;&ensp;{$yd_week}&ensp;&ensp;{$yd_time}</li>

    <li class="li_sum">
      <label>付款方式</label>
      全额付款 ￥
      <if condition="$coach neq ''">
        {:strtotime($user.vip_time) > time() && $user.vip ? $duoxuan_count* ($coach.coach_price+$goods['vip_price']) : $duoxuan_count* $coach.coach_price+$goods['amount'] }
      <else/>
        {:strtotime($user.vip_time) > time() && $user.vip ? $duoxuan_count* $goods['vip_price'] : $goods['amount'] }
      </if>
    </li>
  </ul>
  <a href="javascript:;" class="btn" onClick="add_order()" >
    全额付款￥
    <strong class="sum">
      <if condition="$coach neq ''">
        {:strtotime($user.vip_time) > time() && $user.vip ? $duoxuan_count* ($coach.coach_price+$goods['vip_price']) : $duoxuan_count * $coach.coach_price+$goods['amount'] }
        <else/>
        {:strtotime($user.vip_time) > time() && $user.vip ? $duoxuan_count * $goods['vip_price'] : $goods['amount'] }
      </if>
    </strong>
    立即预定
  </a>
</div>
<!--弹窗 End--> 
<!--main End-->

<script>
  function add_order(){
      ajax_submit('order', "{:U('Home/order/add_order')}");
  }
</script>
</body>
</html>
